from threading import Lock

class Singleton:
    _instance = None
    def __new__(cls, *args, **kwargs):
        if not Singleton._instance:
            lock = Lock()
            lock.acquire()
            if not Singleton._instance:
                cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
            lock.release()
        return cls._instance
